package org.example;
import org.example.bean.Orders;
import org.example.bean.Product;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import java.util.Date;
import java.util.concurrent.Executor;

/**
 * @program: maven3
 * @description:
 * @author: zy
 * @create: 2025-09-09 10:37
 */
public class App2 {
    public static void main(String[] args) {
        ApplicationContext ac=new AnnotationConfigApplicationContext(   AppConfig2.class);
        Orders orders= (Orders) ac.getBean("orders");
        System.out.println(orders);

        Product product= (Product) ac.getBean("p1");
        System.out.println(product);

        Executor executor= (Executor) ac.getBean("threadPool");
        executor.execute(  ()->{
            while(  true ){
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                System.out.println(  new Date() );
            }
        });
    }
}